package org.mzx.shortLink.adminn.remoteApi.workkApi;

import com.baomidou.mybatisplus.core.metadata.IPage;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.mzx.shortLink.adminn.remoteApi.dto.Request.TLinkCountDtoReq;
import org.mzx.shortLink.adminn.remoteApi.dto.Request.TLinkCreateDtoReq;
import org.mzx.shortLink.adminn.remoteApi.dto.Request.TLinkUpdateDtoReq;
import org.mzx.shortLink.adminn.remoteApi.dto.Response.TLinkCreateDtoResp;
import org.mzx.shortLink.adminn.remoteApi.dto.Response.TLinkPageDtoResp;
import org.mzx.shortLink.starter.convention.Result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author mazhenxi
 * @date 2025/5/8
 */
@ComponentScan
@FeignClient(name = "short-link-wrok",contextId = "Link")
public interface feignLinkApi {
    /**
     * 创建短链接
     * @param requestParam
     * @return
     */
    @PostMapping("/api/short-link/v1/create")
    Result<TLinkCreateDtoResp> create(@RequestBody TLinkCreateDtoReq requestParam);

    /**
     * 模拟http请求分页查询
     * @param gid 分组id
     * @param current 目前页数
     * @param size  每页的大小
     * @return  分页
     */
    @GetMapping("/api/short-link/v1/page")
    Result<IPage<TLinkPageDtoResp>> getByPage(@RequestParam("gid") String gid, @RequestParam("current") Long current, @RequestParam("size") Long size, @RequestParam(value = "orderTag",required = false) String orderTag);


    /**
     * 查询某个分组下的短连接数量
     * @param requestParam
     * @return  一个Map
     */
    @PostMapping("/api/short-link/v1/count")
    Result<Map<String, Map<String, Object>>> count(@RequestBody List<TLinkCountDtoReq> requestParam);

    /**
     * 更新短链接
     * @param requestParam
     * @return
     */
    @PostMapping("/api/short-link/v1/update")
    Result update(@RequestBody TLinkUpdateDtoReq requestParam) ;

    /**
     * 得到标题
     * @param url
     * @return
     */
    @GetMapping("/api/short-link/v1/title")
    Result<String> getTitleByUrl(@RequestParam("url") String url) ;

    /**
     * 重定向！核心接口，进行跳转的接口
     * @param shortUrl
     * @return
     */
    @GetMapping("/{short-uri}")
    void reDirect(@PathVariable(value = "short-uri") String shortUrl);
}
